/*
 * CCodeRegister8bit.java
 *
 * Created on March 19, 2007, 11:25 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package moto9s12sim;

/**
 *
 * @author Fergus Earnshaw
 */
public class Register8btCC extends Register{
    
    //flags
    
    //STOP DISABLE
    private boolean blS;
    //MASK
    private boolean blX;
    //HALF-CARRY
    private boolean blH;
    //MASK DISABLE IRQ
    private boolean blI;
    //NEGITIVE
    private boolean blN;
    //ZERO
    private boolean blZ;
    //OVERFLOW
    private boolean blV;
    //CARRY
    private boolean blC;
    
    /** Creates a new instance of CCodeRegister8bit */
    public Register8btCC()
    {
        this.blS = false;
        this.blX = false;
        this.blH = false;
        this.blI = false;
        this.blN = false;
        this.blZ = false;
        this.blV = false;
        this.blC = false;
    }
    
    //set flag funtions
    public void setRegister(byte bTmp)
    {
        //to do code stub to set flags from a byte
        
    }
    public void setS(boolean blTmp)
    {
        this.blS = blTmp;
    }
    
    public void setX(boolean blTmp)
    {
        this.blX = blTmp;
    }
    
    public void setH(boolean blTmp)
    {
        this.blH = blTmp;
    }
    
    public void setI(boolean blTmp)
    {
        this.blI = blTmp;
    }
    
    public void setN(boolean blTmp)
    {
        this.blN = blTmp;
    }
    
    public void setZ(boolean blTmp)
    {
        this.blZ = blTmp;
    }
    
    public void setV(boolean blTmp)
    {
        this.blV = blTmp;
    }
    
    public void setC(boolean blTmp)
    {
        this.blC = blTmp;
    }
    
    //get flag functions
    
    public boolean getS()
    {
        return this.blS;
    }
    
    public boolean getX()
    {
        return this.blX;
    }
    
    public boolean getH()
    {
        return this.blH;
    }
    
    public boolean getI()
    {
        return this.blI;
    }
    
    public boolean getN()
    {
        return this.blN;
    }
    
    public boolean getZ()
    {
        return this.blZ;
    }
    
    public boolean getV()
    {
        return this.blZ;
    }
    
    public boolean getC()
    {
        return this.blC;
    }
    
    public byte getRegister()
    {
        byte bTmp = 0x00;
        
        if(this.blS)
        {
            bTmp = (byte)(bTmp|0x80);
        }
        if(this.blX)
        {
            bTmp = (byte)(bTmp|0x40);
        }
        if(this.blH)
        {
            bTmp = (byte)(bTmp|0x20);
        }
        
        if(this.blI)
        {
            bTmp = (byte)(bTmp|0x10);
        }
        
        if(this.blN)
        {
            bTmp = (byte)(bTmp|0x08);
        }
        
        if(this.blZ)
        {
            bTmp = (byte)(bTmp|0x04);
        }
        
        if(this.blV)
        {
            bTmp = (byte)(bTmp|0x02);
        }
        
        if(this.blC)
        {
            bTmp = (byte)(bTmp|0x01);
        }
        
        return bTmp;
    }
    
    public String printStatusS()
    {
        return ((this.blS)? "ENABLED " : "DISABLED");
    }
    
    public String printStatusX()
    {
        return ((this.blX)? "ENABLED " : "DISABLED");
    }
     
    public String printStatusH()
    {
        return ((this.blH)? "ENABLED " : "DISABLED");
    }
    
    public String printStatusI()
    {
        return ((this.blI)? "ENABLED " : "DISABLED");
    }
    
    public String printStatusN()
    {
        return ((this.blN)? "ENABLED " : "DISABLED");
    }
    
    public String printStatusZ()
    {
        return ((this.blZ)? "ENABLED " : "DISABLED");
    }
    
    public String printStatusV()
    {
        return ((this.blV)? "ENABLED " : "DISABLED");
    }
    
    public String printStatusC()
    {
        return ((this.blC)? "ENABLED " : "DISABLED");
    }
    
    
}
